package controllers;

import connectivity.Dbmanager;
import connectivity.QueryManager;
import java.io.*;
import java.util.LinkedList;
import javax.servlet.*;
import javax.servlet.http.*;
import models.User;

public class UserController extends HttpServlet {

    private Dbmanager dbManager;
    private QueryManager queryManager;
    LinkedList<User> gebruikersLijst;

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {

        dbManager = new Dbmanager();
        dbManager.openConnection();
        queryManager = new QueryManager(dbManager);


        gebruikersLijst = new LinkedList<User>();
        
        gebruikersLijst = queryManager.getallusers();  
        
        request.setAttribute("gebruikersUitSessie", gebruikersLijst); 
        
        String address = "/manage_users.jsp";
        dbManager.closeConnection();
        RequestDispatcher dispatcher = request.getRequestDispatcher(address);
        dispatcher.forward(request, response); //Stuurt door naar de Gebruikers index

    }
}
